<template>
  <div class="add-order">
    <NavBar title="发起售后"></NavBar>

    <van-field
      v-model="formData.content"
      rows="2"
      autosize
      label="填写申请内容"
      type="textarea"
      maxlength="50"
      placeholder="请输入申请内容"
      show-word-limit
    />

    <van-button type="primary" block @click="submit">确定</van-button>
  </div>
</template>

<script>
import NavBar from "../components/NavBar";
export default {
  data() {
    return {
      formData: {
        content: "",
      },
    };
  },
  methods: {
    submit() {
      if (
        !Object.keys(this.formData).every(
          (item) => this.formData[item].length > 0
        )
      ) {
        this.$toast.fail("信息填写错误，请重新检查后提交");
      } else {
        this.$axios
          .put("order/order", {
            ...this.formData,
            id: this.$route.query.orderid,
            status: 1,
          })
          .then((res) => {
            if (res.data.code == 200) {
              this.$router.go(-1);
              this.$toast.success(res.data.msg);
            } else {
              this.$toast.fail("添加失败");
            }
          });
      }
    },
  },
  components: {
    NavBar,
  },
};
</script>

<style scoped lang="scss">
.add-order {
  background-color: #f0f0f0;
  padding-top: 1.1728rem;
  padding-bottom: 1.4928rem;
}
</style>